﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HA.MT3DMS.FileLayer
{
    /// <summary>
    /// 弥散子程序包
    /// </summary>
   public class DispersionPack:Package 
    {
       public DispersionPack()
       {
           this._fileType = FileType.DSP;
           this.Fname = "mt3dms.dsp";
           this._AL = new List<double[,]>();
           this._TRPT = new List<double>();
           this._TRPV = new List<double>();
           this._DMCOEF = new List<double>();
       }
        private List<double[,]> _AL;//模型网格中每个单元的纵向分散性，αL（单位为升（L））
       /// <summary>
        /// 模型网格中每个单元的纵向分散性，αL（单位为升（L））
       /// </summary>
        public  List<double[,]> AL
        {
            get { return _AL; }
            set { _AL = value; }
        }
        private List<double> _TRPT;
       /// <summary>
        /// 一组一维数组，定义水平横向分散性αTH和纵向分散性αL的比值。
        /// 数组中每个数值对应模型的一层。
        /// 近期的一些实地考察建议TRPT一般不会大于0.1
        /// 默认值0.1
       /// </summary>
        public List<double> TRPT
        {
            get { return _TRPT; }
            set { _TRPT = value; }
        }
        private List<double> _TRPV;
       /// <summary>
        /// 竖直横向分散性αTV和纵向分散性αL的比值。
        /// 数组中每个数值对应模型的一层。
        /// 近期的一些实地考察建议TRPT一般不会大于0.01。
        /// 默认值0.01
       /// </summary>
        public List<double> TRPV
        {
            get { return _TRPV; }
            set { _TRPV = value; }
        }

        private List<double> _DMCOEF;
       /// <summary>
       /// 有效分子扩散系数（单位为L2T-1）。如果分子扩散效应不重要，设DMCOEF=0。数组中每个数值对应模型的一层。	
        /// 默认值0
       /// </summary>
        public List<double> DMCOEF
        {
            get { return _DMCOEF; }
            set { _DMCOEF = value; }
        }

        public override void WriteFile(string path)
        {
            string content = "";
            string str = "";
            for (int i = 0; i < this.AL.Count; i++)
            {
                if (IsConstant(this.AL[i]))
                {
                    content += string.Format("{0,10}", GetNumberLengthFormat( 0,10))  + string.Format("{0,10}", GetNumberLengthFormat( this.AL[i][0, 0],10)) + "                                          AL-LAYER " + (i + 1).ToString() + "\r\n";
                }
                else
                {                  
                    GetArrayString(this.AL[i], ref  str);
                   
                    content += str;
                }
            }

            if (IsConstant(this.TRPT))
            {
                content += string.Format("{0,10}",GetNumberLengthFormat(  0,10)) + string.Format("{0,10}",GetNumberLengthFormat(  this.TRPT[0],10)) + "                                          TRPT " + "\r\n";
            }
            else
            {
                GetArrayString(this.TRPT, ref  str);
           
                content += str;
            }

            if (IsConstant(this.TRPV))
            {
                content += string.Format("{0,10}", GetNumberLengthFormat( 0,10))  + string.Format("{0,10}",GetNumberLengthFormat(  this.TRPV[0],10)) + "                                          TRPV " + "\r\n";
            }
            else
            {
                GetArrayString(this.TRPV, ref  str);
               
                content += str;
            }
            if (IsConstant(this.DMCOEF))
            {
                content += string.Format("{0,10}",GetNumberLengthFormat(  0,10))  + string.Format("{0,10}", GetNumberLengthFormat( this.DMCOEF[0],10)) + "                                          DMCOEF " + "\r\n";
            }
            else
            {
                GetArrayString(this.DMCOEF, ref  str);
              
                content += str;
            }


            string fname = path + this.Fname;
            HAUtil.FileOperations.WriteFile(fname, content);
        }
    }
}
